﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UtilZ.Dotnet.Ex.Model
{
    /// <summary>
    /// 泛型名称值类
    /// </summary>
    [Serializable]
    public class NameValue<TValue>
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public NameValue()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="value">值</param>
        public NameValue(TValue value)
        {
            this.Name = value == null ? string.Empty : value.ToString();
            this.Value = value;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="value">值</param>
        public NameValue(string name, TValue value)
        {
            this.Name = name;
            this.Value = value;
        }


        /// <summary>
        /// 获取或设置键
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 获取或设置值
        /// </summary>
        public TValue Value { get; set; }


        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}
